home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 669 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: crchh327.rich.bnr.ca!jobell
  2. From: jobell@bnr.ca (Bret Bieghler)
  3. Newsgroups: comp.lang.c++
  4. Subject: Fishing for Opinions:  Global Variables in GUI
  5. Date: 5 Jan 1996 15:31:56 GMT
  6. Organization: Bell-Northern Research Ltd.
  7. Message-ID: <4cjg9c$m92@crchh327.rich.bnr.ca>
  8. NNTP-Posting-Host: crchh524.rich.bnr.ca
  9.  
  10. Hi.
  11.  
  12. I'm writing a GUI shell to one of our automated systems and have
  13. come across a slight problem.
  14.  
  15. Many people think that global variables are the children of Satan,
  16. but here is a case where I'm not sure what to do.
  17.  
  18. I have an array which contains the status of certain items, yet there
  19. are different ways in the GUI to change their statuses.  So I'd just
  20. like to declare the array globally and allow each callback function
  21. to manipulate it as they see fit.  Is there a way, in C++, to create
  22. a variable that is "global" but only to select functions, since there
  23. are only about three functions that are manipulating this array.
  24.  
  25. Here's what I've done so far:
  26.  
  27. // a bunch of function declarations and definitions:
  28.  
  29. // and then:
  30.  
  31. LIU7 LIU7Array[MAX_LIU7S];
  32. int currentItem;
  33.  
  34. void foobar (callback structs)
  35. {
  36.     // code manipulates LIU7Array
  37. }
  38.  
  39. void moobar (callback structs)
  40. {
  41.     // code manipulates LIU7Array
  42. }
  43.  
  44. // etc.
  45.  
  46. This way I declare the array globally only at the point where the functions
  47. which will access them begin.
  48.  
  49. I tried:
  50.  
  51. // bunch of functions
  52.  
  53. {
  54.     LIU7 LIU7Array[
  55.  
  56.     // code
  57. }    
  58.  
  59. and tried to brace them like a scope but that doesn't work.
  60.  
  61. Any suggestions?
  62.  
  63. E-mail preferred.
  64.  
  65. Thanks,
  66.  
  67. Joe    
  68. -- 
  69. Joseph A. Bell (NOT Bret Bieghler) jobell@bnr.ca
  70. Northern Telecom / Bell-Northern Research
  71. "What?  Evacuate now, in our moment of triumph?  Surely you overestimate their chances."
  72.